-
-
Notifications
You must be signed in to change notification settings - Fork 376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sign update #5797
base: dev/feature
Are you sure you want to change the base?
Sign update #5797
Conversation
bd134d0
to
3f08853
Compare
Changed to a functional interface to support:
Tests failing is not related to this pull request. Fix at #6433 |
…ript into feature/line-signs
src/main/java/ch/njol/skript/classes/data/BukkitEventValues.java
Outdated
Show resolved
Hide resolved
|
||
void setLine(int line, @NotNull String value); | ||
|
||
static void setLine(SetSignLine<Integer, String> setLineMethod, int line, String value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the point of these static methods? Why not just call setLineMethod.setLine(line, value)
directly? Rather than all of these interfaces, I think it would be better just to have a Spigot and Adventure implementations of an interface with set/get methods. The Adventure implementation can handle the string->component conversions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's required to be static, because that's how FunctionalInterface works. One method must be static.
Adventure doesn't exist on Spigot, so you can't rely on Adventure to handle the string to component conversions as the method doesn't exist.
It's a functional interface because AdventureSetSignLine has to be a separate class due to the classes not existing and needing to be statically initialized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be no problem to call the interface methods directly? There's no requirement for there be a static method.
If the Adventure implementation is used only on Paper, I don't see why it would be an issue to handle the component parsing in the interface implantation rather than the syntax's change method. I think the implementation right now is somewhat over complicated for what we need
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't agree with it being more complex. It's making it simpler to read. You have to deal with all the provided methods I posted #5797 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's unnecessary for the Adventure interface to be something we're specifically checking for in change. There should just be an implementation for Adventure of SetSignLine that handles the component conversion (that way adventure doesn't need passed/handled as it's own parameter). Additionally, I'm still not seeing why these static methods are necessary. If you have the interface object, why can't you just call the method it has directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting back to this, I understand the different interfaces, and I see their usefulness, but I don't understand why we can't just use the interface directly. That is, instead of:
SetSignLine.setLine(SET_LINE, i, value)
just call
SET_LINE.setLine(i, value)
Is there a reason this wouldn't work? If there is some sort of error, can you reply with it?
…ript into feature/line-signs
|
||
void setLine(int line, @NotNull String value); | ||
|
||
static void setLine(SetSignLine<Integer, String> setLineMethod, int line, String value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting back to this, I understand the different interfaces, and I see their usefulness, but I don't understand why we can't just use the interface directly. That is, instead of:
SetSignLine.setLine(SET_LINE, i, value)
just call
SET_LINE.setLine(i, value)
Is there a reason this wouldn't work? If there is some sort of error, can you reply with it?
static { | ||
if (Skript.isRunningMinecraft(1, 19, 4)) | ||
serializer = BungeeComponentSerializer.get(); | ||
String addition = RUNNING_1_20 ? "[[on [the] (front|:back) side] of [sign[s]] %blocks%]" : "[of [sign[s]] %blocks%]"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we just use the SignSide type instead?
if (line < 0 || line > 3) | ||
protected String[] get(Event event) { | ||
int line = 0; | ||
if (this.line == null && !multipleLines) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on init
, this will never be true?
|
||
@SuppressWarnings({"unchecked", "null"}) | ||
private Expression<Block> blocks; | ||
private boolean multipleLines; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this not implied by line != null
?
return null; | ||
public Class<?>[] acceptChange(ChangeMode mode) { | ||
boolean acceptsMany = line == null; | ||
switch (mode) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can now return a switch expression
} | ||
|
||
@Override | ||
public String toString(@Nullable Event event, boolean debug) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should support the side
field
Description
Notes:
Target Minecraft Versions: any
Requirements: Paper is optional
Related Issues: #4576 #5778